package com.sky.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;

@Configuration
public class ThreadPoolConflguration {

    @Bean
    public ThreadPoolExecutor threadPoolExecutor() {
        // 任务队列
        ArrayBlockingQueue<Runnable> queue = new ArrayBlockingQueue<>(10);
        // 默认的线程工厂
        ThreadFactory threadFactory = Executors.defaultThreadFactory();
        ThreadPoolExecutor queryThreads = new
                ThreadPoolExecutor(4, 8, 5, TimeUnit.MINUTES,
                queue, threadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
        return queryThreads;
    }

}
